<?php
/*
* Copyright (c) 2010 by Cediti
*
* You may distribute under the terms of either the GNU Lesser General
* Public License or the new BSD License, as specified in the README file.
*/
// created :	31 March 2010
// version :	31 March 2010

class Cmis_Request
{
	const TYPE_REST = 1;
	const TYPE_SOAP = 2;

	/**
	 * Create a protocole binding access
	 * 
	 * @param const $protocol
	 * @param array $protocol_config adapter: the HTTP adapter to use
	 * @param string $login
	 * @param string $password
	 * @param const $auth_type
	 * @return Cmis_Request_Interface
	 */
	public static function factory($protocol, array $protocol_config = null, $login, $password, $auth_type = self::AUTH_HTTP_BASIC, $use_ssl = false)
	{
		$proto = null;
		$http_vendor = (isset($protocol_config['adapter']))?$protocol_config['adapter']:'Curl';
		unset($protocol_config['adapter']);

		switch($protocol)
		{
			default :
				throw new Cmis_Request_Exception('No request type found');
				break;
			case self::TYPE_REST :
				$proto = new Cmis_Request_Rest($login, $password, $auth_type, $use_ssl, $http_vendor);
				break;
			case self::TYPE_SOAP :
				$proto = new Cmis_Request_Soap($login, $password, $auth_type);
				break;
		}

        foreach($protocol_config as $k => $v)
        {
        	$proto->getClient()->setOption($k, $v);
        }

        return $proto;
	}
}

# EOF
